package com.ssm.stu.controller;

import com.ssm.stu.exception.BusinessException;
import com.ssm.stu.exception.SystemException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice {
    @ExceptionHandler(SystemException.class)
    public Result doSystemException(Exception e){
        return new Result(Code.SYSTEM_ERR,null,e.getMessage());
    }

    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(Exception e){
        return new Result(Code.BUSINESS_ERR,null,e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result doUnKnowException(Exception e){
        return new Result(Code.UNKONWN_ERR,null,"系统异常，稍后重试");
    }

}
